package com.fit.pages.coach;

import javax.mail.Session;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.CoachAccess;
import com.fit.dao.coach.CoachDAO;

import com.fit.entities.coach.Coach;
import com.fit.entities.user.User;
import com.fit.pages.ErrorPage;




@AdminAccess
@CoachAccess
public class Add {

	@Property
	private Coach coach;
	@Inject
	private CoachDAO coachDAO;
	@InjectPage
	private ErrorPage errorPage;
	
 

	Object onSuccess() {
		try {
			coachDAO.save(coach);
			return Browse.class;
		
		} catch (Exception e) {
			errorPage.setMessage("Error while adding coach");
			return errorPage;
		}

	}

}
